home *** CD-ROM | disk | FTP | other *** search
/ 1st Multimedia Mac Shareware / Multimedia Shareware CD-ROM - BetaCorp.iso / StackToolsƒ / HyperAppleEventƒ / In-Out Board / stack_-1.xml < prev    next >
Encoding:
Extensible Markup Language  |  1992-03-26  |  7.6 KB  |  25 lines

  1. <?xml version="1.0" encoding="utf-8" ?>
  2. <!DOCTYPE stack PUBLIC "-//Apple, Inc.//DTD stack V 2.0//EN" "" >
  3. <stack>
  4.     <name>in</name>
  5.     <id>-1</id>
  6.     <cardCount>4</cardCount>
  7.     <cardID>2850</cardID>
  8.     <listID>5625</listID>
  9.     <cantModify><false /></cantModify>
  10.     <cantDelete><false /></cantDelete>
  11.     <cantAbort><false /></cantAbort>
  12.     <cardSize>
  13.         <width>288</width>
  14.         <height>220</height>
  15.     </cardSize>
  16.     <script>========================================================================
  17. IN-OUT BOARD
  18. by Danny Goodman
  19.  
  20. Supplement to May 1992 MacUser article on HyperCard and Apple Events
  21. ¬©1991 Danny Goodman
  22. ========================================================================
  23.  
  24. -- Make sure 'server' address is available in this stack
  25. on openStack
  26. if fld "Program Address" is empty then fillAddress
  27. end openStack
  28.  
  29. -- Access program linking dialog to find 'server' address
  30. -- Then store it in local stack field for use by other handlers.
  31. on fillAddress
  32. answer program "Choose the Macintosh and HyperCard running the¬†‚ÄúOut of Office Server.‚Äù"
  33. if it is empty then exit fillAddress
  34. put it into fld "Program Address"
  35. end fillAddress
  36.  
  37. -- Find out if HyperCard is running on the 'server'
  38. -- and whether server stack is active
  39. function InOutIsActive theProgram
  40. request "short name of this stack" from program theProgram
  41. if the result is "No such program" then
  42. answer "The In-Out Server is not responding."
  43. return false
  44. else
  45. if it is "In-Out Board"
  46. then return true
  47. else return false
  48. end if
  49. end InOutIsActive
  50.  
  51. -- Assembles and sends message to server to bring the server
  52. -- stack to the forefront.  Messages and screen are locked to
  53. -- prevent user at the server machine from being distracted
  54. -- by all the window flipping.  Set this as a function to return
  55. -- TRUE when we actually had to go to this stack on the 'server.'
  56. -- That way, we'll know to do a POP after we're finished reading
  57. -- or writing...to put target Mac back in original state.
  58. function goToServer theProgram
  59. put "lock screen" into serverMsg
  60. put "lock messages" into line 2 of serverMsg
  61. put "push card" into line 3 of serverMsg
  62. put "go to stack" && quote & "In-Out Board" & quote into line 4 of serverMsg
  63. send serverMsg to program theProgram
  64. if the result is not empty
  65. then return false
  66. else return true
  67. end goToServer
  68.  
  69. -- These two functions remove and restore carriage return
  70. -- characters in the note text, so that multiple-line notes
  71. -- can be safely stored in a single HyperCard line.
  72. function scrunch theText
  73. put numToChar(16) into delimChar
  74. repeat until offset(return,theText) = 0
  75. put delimChar into char offset(return,theText) of theText
  76. end repeat
  77. return theText
  78. end scrunch
  79.  
  80. function unScrunch theText
  81. put numToChar(16) into delimChar
  82. repeat until offset(delimChar,theText) = 0
  83. put return into char offset(delimChar,theText) of theText
  84. end repeat
  85. return theText
  86. end unScrunch
  87.  
  88. -- Double checks that there is a target program name stored locally.
  89. -- Then directs message to same stack (user and 'server' are
  90. -- on same Mac) or to target program on another Mac.
  91. on startSend
  92. put fld "Program Address" into theProgram
  93. if theProgram is not empty then
  94. if the address is theProgram -- user is also acting as server
  95. then setStatus myStatus()
  96. else sendDataToServer theProgram -- gotta send apple event
  97. end if
  98. end startSend
  99.  
  100. -- Writes information to the 'server' when it is on a different
  101. -- Macintosh.  Calls other functions to check whether target
  102. -- program is running and whether the 'server' stack is running
  103. on sendDataToServer theProgram
  104. global undoRadioBtn,undoNote
  105. if not InOutIsActive(theProgram) then
  106. if goToServer(theProgram)
  107. then put true into needToPop -- we pushed to get here
  108. else
  109. answer "Problem accessing the In-Out Server."
  110. repeat with x = 1 to 7
  111. set hilite of bg btn x to false
  112. end repeat
  113. if there is a bg btn undoRadioBtn
  114. then set hilite of bg btn undoRadioBtn to true
  115. put undoNote into fld "Note"
  116. exit sendDataToServer
  117. end if
  118. end if
  119. send "setStatus" && quote & myStatus() & quote & "" to program theProgram
  120. if needToPop is true -- must restore target HC to former stack
  121. then send "pop card" to program theProgram
  122. end sendDataToServer
  123.  
  124. -- Assembles data from radio buttons and note field into the
  125. -- data line that ultimately gets stored on the 'server.'
  126. function myStatus
  127. global userName
  128. if userName is empty then
  129. answer "Go to last card of Home stack and enter your userName"
  130. exit myStatus
  131. end if
  132. put numToChar(15) into itemDelim
  133. repeat with x = 1 to 7
  134. if hilite of bg btn x then
  135. put short name of bg btn x into theStatus
  136. exit repeat
  137. end if
  138. end repeat
  139. return userName & itemDelim & theStatus & itemDelim & scrunch(fld "Note")
  140. end myStatus
  141.  
  142. -- Executes only when the user is also the 'server.'
  143. -- Writes new data to the hidden "Group Status" field.
  144. -- Handler uses the user name to find the line number containing
  145. -- any previous entry for the user.  If there is none, then it
  146. -- appends the data to the end of the field.
  147. on setStatus theData
  148. set itemDelimiter to numToChar(15)
  149. put item 1 of theData & numToChar(15) into theName
  150. set itemDelimiter to comma
  151. put lineNumber(theName,fld "Group Status" of cd 1) into whichLine
  152. if whichLine ‚â§ 0
  153. then put (number of lines of fld "Group Status" of cd 1) + 1 into whichLine
  154. put theData into line whichLine of fld "Group Status" of cd 1
  155. end setStatus
  156.  
  157. ==========
  158. -- Handlers called by other users when the stack is the 'server.'
  159.  
  160. -- Writes new data to the hidden "Group Status" field.
  161. -- Handler uses the user name to find the line number containing
  162. -- any previous entry for the user.  If there is none, then it
  163. -- appends the data to the end of the field.
  164. -- Also executes when the user is also the 'server.'
  165. on setStatus theData
  166. set itemDelimiter to numToChar(15)
  167. put item 1 of theData & numToChar(15) into theName
  168. set itemDelimiter to comma
  169. put lineNumber(theName,fld "Group Status" of cd 1) into whichLine
  170. if whichLine ‚â§ 0
  171. then put (number of lines of fld "Group Status" of cd 1) + 1 into whichLine
  172. put theData into line whichLine of fld "Group Status" of cd 1
  173. end setStatus
  174.  
  175. -- A fast way to find which line of a container holds some text.
  176. function lineNumber matchText,fullText
  177. return (number of lines of char 1 to offset(matchText,fullText) of fullText)
  178. end lineNumber
  179.  
  180. -- Retrieves a list of names only from the data field.  References
  181. -- are to cd 1 in case the person on the 'server' machine is
  182. -- in the In-Out stack, but on a different card.
  183. function userList
  184. put empty into theUsers
  185. set itemDelimiter to numToChar(15)
  186. push card
  187. if there is no fld "Group Status" of cd 1 then
  188. lock screen
  189. lock messages
  190. go to stack "In-Out Board"
  191. end if
  192. get fld "Group Status" of cd 1
  193. repeat with x = 1 to number of lines of it
  194. put item 1 of line x of it into line x of theUsers
  195. end repeat
  196. pop card
  197. unlock screen
  198. unlock messages
  199. return theUsers
  200. end userList
  201.  
  202. -- Retrieves the entire line of information for a given name.
  203. -- Parsing of the data is left to the local stack, keeping
  204. -- processing time on the shared stack to a minimum.
  205. function userData theName
  206. put numToChar(15) after theName
  207. put lineNumber(theName,fld "Group Status" of cd 1) into whichLine
  208. return line whichLine of fld "Group Status" of cd 1
  209. end userData
  210. </script>
  211.     <background id="2814" file="background_2814.xml" name="Mine" />
  212.     <background id="4190" file="background_4190.xml" name="Other" />
  213.     <background id="4820" file="background_4820.xml" name="" />
  214.     <card id="2850" file="card_2850.xml" marked="false" name="Current Status" owner="2814" />
  215.     <card id="3904" file="card_3904.xml" marked="false" name="Other" owner="4190" />
  216.     <card id="4957" file="card_4957.xml" marked="false" name="About" owner="4820" />
  217.     <card id="5305" file="card_5305.xml" marked="false" name="Help" owner="4820" />
  218. </stack>
  219.